﻿@using ZBJF.Warranty.BLL
@model List<ZBJF.Warranty.Model.SellerEmployeeRole>
@{
    using (Html.BeginForm("SaveSellerEmployeeRoleMapping", "SellerEmployee", FormMethod.Post, new { id = "mvcForm", name = "mvcForm", @class = "form-horizontal", enctype = "multipart/form-data" }))
    {
        var sellerEmployeeID = 0;
        if (!int.TryParse(Request["SellerEmployeeID"], out sellerEmployeeID))
        {
            <text>没有找到该员工信息</text>;
            return;
        }
        var employee = ServiceFactory.SellerEmployeeServiceInstance.LoadByID(sellerEmployeeID);
        var employeeRoles = ServiceFactory.SellerEmployeeRoleMappingServiceInstance.LoadByEmployeeID(sellerEmployeeID);
        var roleIds = employeeRoles.Select(o => o.SellerEmployeeRoleID).ToList();
        @Html.Hidden("SellerEmployeeID", sellerEmployeeID);
    <div class="control-group">
        <label class="control-label w-100">员工姓名:</label>
        <div class="controls margin-l-120">
            <label class="padding-t-0">
                @employee.UserName
            </label>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label w-100">角色:</label>
        <div class="controls margin-l-120">
            @{
                                                          var count = 1;
                                                          foreach (var item in Model)
                                                          {
                                                            <label class="padding-l-5 w-120">
                                                                <input name="SellerEmployeeRoleID" @(roleIds.Contains(item.ID) ? "checked=checked" : "") type="checkbox" value="@item.ID" />
                                                                @item.RoleName
                                                            </label>
                                                              if (count % 2 == 0)//一行显示n个
                                                              {
                                                                <br />
                                                              }
                                                              count++;
                                                          }
            }
        </div>
    </div>
    <div class="align-center">
        <input id="btnSubmit" class="btn btn-primary Edit-R" type="submit" value="提交">
        <input id="btnCancel" class="btn" type="button" value="取消" onclick="parent.layer.closeAll()">
    </div>
    }
}
